<?php 
/** Zend_Controller_Action */ 
ob_start() ;
require_once ROOT_PATH . '/library/Soooner/Controller/Action.php';
require_once ROOT_PATH .('/library/Common/Connectors/config.php') ;
require_once ROOT_PATH .('/library/Common/Connectors/util.php') ;
require_once ROOT_PATH .('/library/Common/Connectors/io.php') ;
require_once ROOT_PATH .('/library/Common/Connectors/basexml.php') ;
require_once ROOT_PATH .('/library/Common/Connectors/commands.php') ;
require_once ROOT_PATH .('/library/Common/Connectors/phpcompat.php') ;

class ConnectorsController extends Soooner_Controller_Action
{
	public function connectorAction()
	{
		//echo Server_MapPath("/upload/");exit;
		
		$sCommand		= $_GET['Command'] ;
		$sResourceType	= $_GET['Type'] ;
		$sCurrentFolder	= GetCurrentFolder() ;	
		$sCurrentFile	= $_GET['File'] ;
		
		//echo GetResourceTypeDirectory($sResourceType,$sCommand);exit;
		
		if ( $sCommand == 'FileUpload' )
		{
			FileUpload( $sResourceType, $sCurrentFolder, $sCommand ) ;
			return ;
		}
		CreateXmlHeader( $sCommand, $sResourceType, $sCurrentFolder ) ;
		// Execute the required command.
		switch ( $sCommand )
		{
			case 'GetFolders' :
				GetFolders( $sResourceType, $sCurrentFolder ) ;
				break ;
			case 'GetFoldersAndFiles' :
				GetFoldersAndFiles( $sResourceType, $sCurrentFolder ) ;
				break ;
			case 'CreateFolder' :
				CreateFolder( $sResourceType, $sCurrentFolder ) ;
				break ;
			case 'DeleteFile':
				DeleteFile( $sResourceType, $sCurrentFolder, $sCurrentFile ) ;	
				break ;
		}	
		CreateXmlFooter() ;	
		exit ;
	}
	public function uploadAction()
	{
		$sCommand = 'QuickUpload' ;
		$sType = isset( $_GET['Type'] ) ? $_GET['Type'] : 'File' ;		
		$sCurrentFolder	= "/" ;
		//echo $sServerDir= ServerMapFolder( $resourceType, $currentFolder, $sCommand ) ;
		//echo str_replace("/index.php","/$sType",$sServerDir);
		//exit;
		FileUpload( $sType, $sCurrentFolder, $sCommand );
	}
}
